﻿using App.Model;
using App.Model.DTO.Article;
using App.Model.DTO.Classification;
using App.Model.DTO.photo;
using App.Model.DTO.PhotoCategory;
using App.Model.DTO.Role;
using App.Model.DTO.User;
using AutoMapper;

namespace App.WebAPI.Utilty._AutoMapper
{
    public class CustomAutoMapperProfile:Profile
    {
        public CustomAutoMapperProfile()
        {
            base.CreateMap<Role, RoleDTO>();
            base.CreateMap<UserInfo, UserDTO>()
                .ForMember(dest => dest.RoleName, sourse => sourse.MapFrom(src => src.Role.Name));
            base.CreateMap<Classification, ClassificationDTO>();
            base.CreateMap<Article, ArticleDTO>()
                .ForMember(dest => dest.ClassificationName, sourse => sourse.MapFrom(src => src.Classification.Name))
                .ForMember(dest => dest.NickName, sourse => sourse.MapFrom(src => src.UserInfo.NickName));
            base.CreateMap<Photo, PhotoDTO>();
            base.CreateMap<PhotoCategory, PhotoCategoryDTO>();
        }
    }
}
